home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / DATETIME.SWG / 0009_DATEFRMT.PAS.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  3KB  |  143 lines

  1. (*
  2. > Function SYS_DATE : STR8; { Format System Date as YY/MM/DD }
  3.  
  4.        No doubt, your Function will work.  But don't you think that nowadays
  5. Programmers, even if they live in the United States, should Write software
  6. which is a little bit more open-minded?  The date Format "YY/MM/DD" is commonly
  7. used in your country, but in the country where I live "DD-MM-YY" is standard,
  8. and in other countries there are other date and time Formats in use.
  9.  
  10.        Dates expressed in your country Format appear somewhat strange and
  11. bizarre outside the US.  I wonder why most American Programmers don't care
  12. about the country support alReady built-in into Dos.  Is this arrogance or does
  13. this indicate a somewhat narrow-minded American way of thinking?
  14.  
  15.        Use the following Unit to determine the current country settings Valid
  16. on the Computer your Program is operating on:
  17. *)
  18.  
  19. Unit country;
  20.  
  21. Interface
  22.  
  23. Type
  24.   str4 = String[4];
  25.  
  26. Function countryCode      : Byte;
  27. Function currencySymbol   : str4;
  28. Function dateFormat       : Word;
  29. Function dateSeparator    : Char;
  30. Function DecimalSeparator : Char;
  31. Function timeSeparator    : Char;
  32.  
  33.  
  34. Implementation
  35. Uses
  36.   Dos;
  37.  
  38. Type
  39.   countryInfoRecord = Record
  40.     dateFormat     : Word;
  41.     currency       : Array[1..5] of Char;
  42.     thouSep,
  43.     DecSep,
  44.     dateSep,
  45.     timeSep        : Array[1..2] of Char;
  46.     currencyFormat,
  47.     significantDec,
  48.     timeFormat     : Byte;
  49.     CaseMapAddress : LongInt;
  50.     dataListSep    : Array[1..2] of Char;
  51.     reserved       : Array[1..5] of Word
  52.   end;
  53.  
  54. Var
  55.   countryRecord : countryInfoRecord;
  56.   reg           : Registers;
  57.  
  58.  
  59. Procedure getCountryInfo; { generic Dos call used by all Functions }
  60.  
  61. begin
  62.  
  63.   reg.AH := $38;
  64.   reg.AL := 0;
  65.   reg.DS := seg(countryRecord);
  66.   reg.DX := ofs(countryRecord);
  67.   msDos(reg)
  68.  
  69. end; { getCountryInfo }
  70.  
  71.  
  72. Function countryCode : Byte; { returns country code as set in Config.Sys }
  73.  
  74. begin
  75.  
  76.   countryCode := reg.AL
  77.  
  78. end; { countryCode }
  79.  
  80. Function currencySymbol : str4; { returns currency symbol }
  81. Var
  82.   temp : str4;
  83.   i    : Byte;
  84.  
  85. begin
  86.  
  87.   With countryRecord do
  88.   begin
  89.     temp := '';
  90.     i := 0;
  91.     Repeat
  92.       Inc(i);
  93.       if currency[i] <> #0 then temp := temp + currency
  94.     Until (i = 5) or (currency[i] = #0)
  95.   end;
  96.   currencySymbol := temp
  97.  
  98. end; { currencySymbol }
  99.  
  100.  
  101. Function dateFormat : Word;
  102. { 0 : USA    standard mm/dd/yy }
  103. { 1 : Europe standard dd-mm-yy }
  104. { 2 : Japan  standard yy/mm/dd }
  105. begin
  106.  
  107.   dateFormat := countryRecord.dateFormat
  108.  
  109. end; { dateFormat }
  110.  
  111.  
  112. Function dateSeparator : Char; { date separator Character }
  113.  
  114. begin
  115.  
  116.   dateSeparator := countryRecord.dateSep[1]
  117.  
  118. end; { dateSeparator }
  119.  
  120.  
  121. Function DecimalSeparator : Char; { Decimal separator Character }
  122.  
  123. begin
  124.  
  125.   DecimalSeparator := countryRecord.DecSep[1]
  126.  
  127. end; { DecimalSeparator }
  128.  
  129.  
  130. Function timeSeparator : Char; { time separator Character }
  131.  
  132. begin
  133.  
  134.   timeSeparator := countryRecord.timeSep[1]
  135.  
  136. end; { timeSeparator }
  137.  
  138. begin
  139.  
  140.   getCountryInfo
  141.  
  142. end. { Unit country }
  143.